<?php
defined('IN_TS') or die('Access Denied.');

$userid = aac('user')->isLogin();

//判断发布者状态
if(aac('user')->isPublisher()==false) tsNotice('不好意思，你还没有权限发布内容！');

switch($ts){

	case "":
		$arrOptions = $new['task']->findAll('task_options');
		foreach($arrOptions as $item){
			$strOption[$item['optionname']] = stripslashes($item['optionvalue']);
		}
		$arrGroup = $new['task']->findAll('group','isplace=2','groupid asc');
		if ($strOption['allowpost'] == 0 && $TS_USER['isadmin'] == 0) {
//        if ($TS_APP['allowpost'] == 0 && $TS_USER['isadmin'] == 0) {
            tsNotice('系统设置不允许会员发任务！');
        }

		$title = '发布任务';
		include template("add");
	
		break;
	
	case "do":
	
		$title = trim($_POST['title']);
		$typeid = intval($_POST['typeid']);
		$limittime = $_POST['limittime'];
		$quota =  intval($_POST['quota']);
		$timelong =  intval($_POST['timelong']);
		$content = tsClean($_POST['content']);
		$limittime = strtotime($limittime);

		$count = count($img_path);

		if($title == '' || $content == ''){
			tsNotice('标题和内容不能为空');
		}

        //1审核后显示0不审核
        if ($TS_APP['isaudit'] == 1) {
            $isaudit = 1;
        } else {
            $isaudit = 0;
        }


		
		$taskid = $new['task']->create('task',array(
			
			'userid'	=> $userid,
			'title'	=> $title,
			'typeid' => $typeid,
			'content' => $content,
			'limittime'=>$limittime,
			'timelong'=>$timelong,
			'quota'=>$quota,
			'isaudit'=>$isaudit,
			'addtime'	=> time(),
		));



		header("Location: ".tsUrl('task','show',array('id'=>$taskid)));
	
		break;
		
	//地图 
	case "map":
	
		$dd = isset($_GET['dd']) ? $_GET['dd'] : '中国北京';

		include template('add_map');
	
		break;

}